git status
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Hello.txt
no changes added to commit (use "git add" and/or "git commit -a")
git add
以及git commit
$ git add .
$ git commit -m "This commit is for git log~~"
[master c1bd3b4] This commit is for git log~~
1 file changed, 1 insertion(+)
git log
,這個指令可以讓我們看到之前到底有哪些Commit內容$ git log
commit c1bd3b47badc91da05cad85e6beab0fa9b835c06 (HEAD -> master)
Author: jackey10055206 <jackey10055206@gmail.com>
Date: Fri Sep 18 09:32:30 2020 +0800
This commit is for git log~~
commit 3334501698721c0e89bfe6b586f62cbe295bf4d6
Author: jackey10055206 <jackey10055206@gmail.com>
Date: Fri Sep 18 09:26:23 2020 +0800
This file is for you!!
你可以從上面的東西看出以下的內容
恩這就是git log
的功用啦~當然了,git log
後面還可以掛很多參數
$ git log --oneline #以一行的方式輸出Git log
c1bd3b4 (HEAD -> master) This commit is for git log~~
3334501 This file is for you!!
$git log --graph #以圖形的方式輸出Git log
* commit c1bd3b47badc91da05cad85e6beab0fa9b835c06 (HEAD -> master)
| Author: jackey10055206 <jackey10055206@gmail.com>
| Date: Fri Sep 18 09:32:30 2020 +0800
|
| This commit is for git log~~
|
* commit 3334501698721c0e89bfe6b586f62cbe295bf4d6
Author: jackey10055206 <jackey10055206@gmail.com>
Date: Fri Sep 18 09:26:23 2020 +0800
This file is for you!!
$ git log --oneline --grep "git log" #grep可以放你想要搜尋的東西
c1bd3b4 (HEAD -> master) This commit is for git log~~
$git log --oneline --author "jackey10055206" #author用來找特定的人發了什麼Commit
c1bd3b4 (HEAD -> master) This commit is for git log~~
3334501 This file is for you!!
$ git log --pretty=format:"%h - %an, %ar : %s"
c1bd3b4 - jackey10055206, 20 minutes ago : This commit is for git log~~
3334501 - jackey10055206, 26 minutes ago : This file is for you!!
補充一個冷知識,Commit時的訊息不是有一個長得很像亂碼的嗎?
(c1bd3b47badc91da05cad85e6beab0fa9b835c06
)
就像上面這樣
其實這是一個SHA-1演算法所得到的結果
你可以把他想成是一種身分證的概念
每一個Commit都會有一個自己的SHA-1
好啦今天謝謝各位的收看啦,我們明天再見
在commit完後我再輸入git status出現這行On branch master
nothing to commit, working tree clean而非您圖片所顯示的是為什麼呢
是正常的哦! 我那個圖片是"我對檔案做出了修改,但還沒對檔案進行commit的動作"